package com.dwin.h5.app;

import android.content.Context;
import android.content.res.Configuration;
import android.support.multidex.MultiDexApplication;
import android.util.Log;

import com.dwin.h5.app.h5.H5MessageTool;
import com.dwin.h5.app.models.WeatherModel;
import com.dwin.h5.app.utils.LocalManageUtil;
import com.tencent.smtt.sdk.QbSdk;

import org.litepal.LitePal;

//import cn.jpush.android.api.JPushInterface;

import static com.dwin.h5.app.utils.Constants.IS_HBDC3D;

public class H5Application extends MultiDexApplication {

    public static H5MessageTool h5MessageTool;
    public static double lat;
    public static double lng;
    public static String device_bssid = "";
    public static String nation = "中国";
    public static WeatherModel.AddressComponent addressComponent;

//    public static ConfigureDeviceInfo configureDeviceInfo;

    @Override
    protected void attachBaseContext(Context base) {
        super.attachBaseContext(LocalManageUtil.setLocal(base));
        LitePal.initialize(this);
    }

    @Override
    public void onConfigurationChanged(Configuration newConfig) {
        super.onConfigurationChanged(newConfig);
        LocalManageUtil.setLocal(this);
    }


    @Override
    public void onCreate() {
        super.onCreate();
//        if (IS_HBDC3D) {
//            JPushInterface.setDebugMode(true);    // 设置开启日志,发布时请关闭日志
//            JPushInterface.init(this);            // 初始化 JPush
//        }
        h5MessageTool = new H5MessageTool();

        //搜集本地tbs内核信息并上报服务器，服务器返回结果决定使用哪个内核。
        QbSdk.PreInitCallback cb = new QbSdk.PreInitCallback() {
            @Override
            public void onViewInitFinished(boolean arg0) {
                //x5內核初始化完成的回调，为true表示x5内核加载成功，否则表示x5内核加载失败，会自动切换到系统内核。
                Log.d("app", " onViewInitFinished is " + arg0);
            }
            @Override
            public void onCoreInitFinished() {
            }
        };
        //x5内核初始化接口
        QbSdk.initX5Environment(getApplicationContext(), cb);
    }

}
